<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">


	$(function() {
		
		$('#departmentId').combobox({
			url : '${ctx}/department/listName',
			valueField: 'id',
			textField: 'text'
		});
		
		$('#roleId').combobox({
		    url: '${ctx}/role/listName',
		    valueField: 'id',
			textField: 'text'
		});
		
		$('#userAddForm').form({
			url : '${ctx}/user/add',
			onSubmit : function() {
				progressLoad();
				var isValid = $(this).form('validate');
				if (!isValid) {
					progressClose();
				}
				return isValid;
			},
			success : function(result) {
				progressClose();
				result = $.parseJSON(result);
				if (result.status.errorCode == 0) {
					parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
					parent.$.modalDialog.handler.dialog('close');
				} else {
					parent.$.messager.alert('提示', result.status.errorMsg, 'warning');
				}
			}
		});
	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false"  style="padding: 3px;">
		<form id="userAddForm" method="post">
			<table class="grid">
				<tr>
					<td>用户名</td>
					<td><input name="username" type="text" class="easyui-validatebox" data-options="required:true,validType:'account[1,16]'"></td>
					<td>密码</td>
					<td><input name="password" type="password" class="easyui-validatebox" data-options="required:true,validType:'account[1,16]'"></td>
				</tr>
				<tr>
					<td>姓名</td>
					<td><input name="name" type="text" class="easyui-validatebox" data-options="required:true,validType:'chinese[2,4]'"></td>
					<td>年龄</td>
					<td><input type="number" name="age" class="easyui-validatebox" data-options="validType:['checkNum','length[1,3]']"/></td>
				</tr>
				<tr>
					<td>性别</td>
					<td><select name="sex" class="easyui-combobox" data-options="width:140,height:29,editable:false,panelHeight:'auto'">
						<c:forEach items="${sexList}" var="sexList">
							<option value="${sexList.key}" >${sexList.value}</option>
						</c:forEach>
					</select></td>
					<td>手机</td>
					<td><input name="cellphone"  type="text" class="easyui-validatebox" data-options="validType:['checkNum','length[11,11]']" /></td>
				</tr>
				<tr>
					<td>身份证号</td>
					<td><input name="idNumber"  type="text" class="easyui-validatebox" data-options="required:true,validType:'idcard'" /></td>
					<td>科室</td>
					<td><select id="departmentId" name="departmentId" style="width: 140px; height: 29px;"></select></td>
				</tr>
				<tr>
					<td>角色</td>
					<td><select id="roleId" name="roleId" style="width: 140px; height: 29px;"></select></td>
				</tr>
				<tr>
					<td>描述(1024以内)</td>
					<td colspan="3"><textarea name="description" rows="15" cols="80" maxlength="1024"></textarea></td>
				</tr>
			</table>
		</form>
	</div>
</div>